/*
 * protocol.h
 *
 *  Created on: Dec 3, 2012
 *      Author: root
 */

#ifndef __PROTOCOL_H_
#define __PROTOCOL_H_

#define TYPE_REQ_LS 0x01
#define TYPE_REQ_WRITE 0x02
#define TYPE_REQ_READ 0x04
#define TYPE_RES_READ 0x05
#define TYPE_REQ_MKDIR 0x06
#define TYPE_RES_OK 0x07
#define TYPE_REQ_RMDIR 0x08

struct req_ls {
	char dirname[256];
};

struct res_ok {
	char isok;
};

struct req_mkdir {
	char dirname[256];
};

struct req_rmdir {
	char dirname[256];
};

struct req_read {
	char filepath[256];
	int pos;
	int size;
};

struct res_read {
	char data[256];
	int size;
};

struct req_write {
	char filepath[256];
	char data[256];
	int pos;
	int size;
};

int request_protocol(byte req_type, void *req_ptcl, int req_ptcl_len,
		void *res_ptcl, int res_ptcl_len, struct socket *sock);
int length_protocol(int ptcl_type);

#endif // __PROTOCOL_H_
